import React from 'react'
import { Input, Select } from 'antd';
import { BaseListPage, IBaseListPageProps, IBaseListPageState, UdSelectAjax, http, columnRenders } from '../../../lib/index'
import apis from '@/apis/CaseConfirmation'

const Option = Select.Option

interface IRepairListProps extends IBaseListPageProps { }

interface IRepairListState extends IBaseListPageState { }

//接口字段映射
const fieldMap = {
  //执行案编号
  id: "name",
  //费用类型
  type: "costTypeC",
  //销售组织代码
  salesOrganizationCode: "salesOrganizationCode",
  //销售组织
  salesOrganization: "budgCompC",
  //执行对象编码
  executionCode: "benfObjCodeC",
  //执行对象名称
  executionName: "customerName",
  //确认状态
  status: "statusC",
  //执行案申请说明
  discription: "applicationDescriptionC",
  //确认时间
  date: "checkTime"
}

export default class CaseConfirmationRecord extends BaseListPage<IRepairListProps, IRepairListState> {

  constructor(props: IRepairListProps) {
    super(props)
    //页面配置
    this.state = {
      //标题
      title: '执行案确认记录',
      //表单请求地址
      queryApi: apis.List,
      rowKey: 'id',
      //搜索项配置
      conditions: [
        { id: fieldMap.id, label: '执行案编号', },
        { id: fieldMap.type, label: '费用类型', },
        { id: fieldMap.salesOrganization, label: "销售组织" },
        { id: fieldMap.executionCode, label: "执行对象编码" },
        { id: fieldMap.executionName, label: "执行对象名称" },
        { id: fieldMap.status, label: "确认状态", render: () => 
          <Select>
            <Option value="已确认">已确认</Option>
            <Option value="未确认">未确认</Option>
          </Select>
        }
      ],
      //表格项配置
      columns: [
        ["执行案编号", fieldMap.id, null, { minWidth: '80px' }],
        ["执行案申请说明", fieldMap.discription, (text) => {
          return <div>{text}</div>
        }, { width: '24%', minWidth: '220px', ellipsis: true,  className: 'ellipsis-td' }],
        ["费用类型", fieldMap.type, null, { minWidth: '100px' }],
        ["销售组织", fieldMap.salesOrganization, null, { minWidth: '200px' }],
        ["执行对象编码", fieldMap.executionCode, null, { minWidth: '80px' }],
        ["执行对象", fieldMap.executionName, null, { minWidth: '120px' }],
        ["确认状态", fieldMap.status, (text,record)=>{
          let render = '未确认'
          if(record[fieldMap.date]) {
            render = '已确认' 
          }
          return render
        }, { minWidth: '60px' }],
        ["确认时间", fieldMap.date, null, { minWidth: '120px' }],
      ],
      tableProps: {
        scroll: { x: true },
      }
    }
  }

}
